/* 物料大类（t_goodsclass）12110列表，12111查询，12112 添加，12113修改，12114删除*/
/*
 *
 * 参数   交易码：trancode=12110
 * 
 */

package org.ccams.tran;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import org.ccams.domain.TGoodsclass;
import org.ccams.util.PageParameter;
/**
 * 物料大类展示
 * @author liuguangshuai@gmail.com
 * 系统名称：定制化辅助生产制造系统
 * 时间：Oct 16, 2008
 */
public class Tran12110 extends AbstractJsonTran {

	@SuppressWarnings("unchecked")
	public void buildJSONObject(Map model, JSONObject json,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		int limit = Integer.parseInt(request.getParameter("limit"));
		int start = Integer.parseInt(request.getParameter("start"));
		PageParameter page = new PageParameter();
		page.setLimit(limit);
		page.setStart(start);
		HashMap<String, Object> jsonMap = new HashMap<String, Object>();
		ArrayList<TGoodsclass> al = new ArrayList<TGoodsclass>();
		List<TGoodsclass> list = getCcamsService().getTgoodsclassDao().getTGoodsclass(page);
		int count = getCcamsService().getTgoodsclassDao().getCount();
		for(TGoodsclass t : list){
			TGoodsclass tm = new TGoodsclass();
			tm.setClassname(t.getClassname());
			tm.setClassno(t.getClassno());
			tm.setFormula(t.getFormula());
			tm.setGrade(t.getGrade());
			tm.setIdtGoodsclass(t.getIdtGoodsclass());
			al.add(tm);
		}


		JSONArray JsonArray = JSONArray.fromObject(al); //得到JSON数组 
		jsonMap.put("totalProperty", count);
        jsonMap.put("root", JsonArray);
        json.putAll(jsonMap);
	}
}
